package com.luyou.a04;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author 28336
 * @version 1.0
 * Create by 2023/12/11 8:46
 */
public class Bean1 {

    private Bean2 bean2;

    private Bean3 bean3;

    private String home;

    @Autowired
    public void setBean2(Bean2 bean2){
        System.out.println("@Autowired 生效："  + bean2);
        this.bean2 = bean2;
    }


    @Resource
    public void setBean3(Bean3 bean3){
        System.out.println("@Autowired 生效："  + bean3);
        this.bean3 = bean3;
    }

    @Autowired
    public void setHome(@Value("${JAVA_HOME}") String home){
        System.out.println("@Value 生效：" + home);
    }

    @PostConstruct
    public void init(){
        System.out.println("@PostConstruct 生效");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("@PreDestroy 生效");
    }
}
